<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<ui:composition template="../template/layout.xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	<ui:param name="pageHeaderTitle" value="Treatment request" />
	<ui:define name="content">
		<br />
		<h2 style="text-align: center">Treatment request</h2>
		<div id="inner_content">
			<h:form>
				<h:panelGrid columns="2" cellpadding="4" styleClass="viewClientGrid"
					columnClasses="viewClientGridColumn1, viewClientGridColumn2" >

					<h:panelGroup>
						<p:outputLabel value="Patient: " style="font-weight:bold" />
					</h:panelGroup>

					<h:panelGroup>
						<h:outputText
							value="#{viewTreatmentRequestBean.treatmentRequest.act.client.firstName} #{viewTreatmentRequestBean.treatmentRequest.act.client.lastName}" />
					</h:panelGroup>

					<h:panelGroup>
						<p:outputLabel value="Meet time: " style="font-weight:bold" />
					</h:panelGroup>

					<h:panelGroup layout="block">

						<p:calendar
							value="#{viewTreatmentRequestBean.treatmentRequest.meetDate}"
							id="meetDate" showOn="button" styleClass="pCalendar"
							converter="stringToCalendarConverterNoTime"
							pattern="MM/dd/yyyy" 
							mindate="c" 
							readonly="#{facesContext.renderResponse}">
						</p:calendar>
						<br />
						<div style="margin-top: 8px; margin-bottom: 8px">
						<p:outputLabel value="Hour: " for="meetHour" /><p:outputLabel value="Minutes: " for="meetMinute" style="margin-left: 72px" />
						</div>						
						<p:selectOneMenu id="meetHour" panelStyle="width:100px"
							style="width:110px" value="#{viewTreatmentRequestBean.selectedHour}">				
							<f:selectItems value="#{viewTreatmentRequestBean.hourList}" />
						</p:selectOneMenu>												
						<p:selectOneMenu id="meetMinute" panelStyle="width:100px"
							style="width:110px; margin-left:10px" value="#{viewTreatmentRequestBean.selectedMinute}">				
							<f:selectItems value="#{viewTreatmentRequestBean.minuteList}" />
						</p:selectOneMenu>												

					</h:panelGroup>

					<h:panelGroup>
						<p:outputLabel value="Accepted: " style="font-weight:bold" />
					</h:panelGroup>

					<h:panelGroup
						rendered="#{request.isUserInRole('Doctor') and not request.isUserInRole('Receptionist')}">

						<p:selectOneMenu id="selectAcceptStatus" panelStyle="width:150px"
							converter="stringToStatusConverter" style="width:160px"
							value="#{viewTreatmentRequestBean.treatmentRequest.acceptStatus}">
							<f:selectItem itemLabel="Yes" itemValue="#{true}" />
							<f:selectItem itemLabel="No" itemValue="#{false}" />
						</p:selectOneMenu>

					</h:panelGroup>

					<h:panelGroup rendered="#{request.isUserInRole('Receptionist')}">
						<h:outputText
							value="#{viewTreatmentRequestBean.treatmentRequest.acceptStatus}"
							converter="stringToStatusConverter" />
					</h:panelGroup>

					<h:panelGroup>
						<br />
						<p:commandButton value="Save"
							action="#{viewTreatmentRequestBean.updateRequest()}" style="width: 95px"
							styleClass="pCommandButton" update=":menu_info" />
					</h:panelGroup>

					<h:panelGroup>
					</h:panelGroup>

					<h:panelGroup>
						<h:form>
							<p:commandButton value="Delete"
							onclick="confirmation.show();return false;" style="margin-left: 0px" styleClass="pDeleteButton" />

							<p:confirmDialog message="Are you sure want to delete request?"
								widgetVar="confirmation">
								<p:commandButton value="Yes" onclick="confirmation.hide()"
									actionListener="#{viewTreatmentRequestBean.deleteRequest}">
								</p:commandButton>
								<p:commandButton value="No" onclick="confirmation.hide()"
									type="button" />
							</p:confirmDialog>

						</h:form>
					</h:panelGroup>
					
					<h:panelGroup>					
					</h:panelGroup>
					
					<h:panelGroup>
						
							<h:outputLink value="../rec/viewTreatmentAct.xhtml" >
								<h:outputText value="Treatment act" />
							    <f:param name="reqId" value="#{viewTreatmentRequestBean.reqId}" />
							    <f:param name="actId" value="#{viewTreatmentRequestBean.treatmentRequest.act.id}" />						    
							</h:outputLink>
						
					</h:panelGroup>					

				</h:panelGrid>
			</h:form>
		</div>
		<br />
		<br />
		<h:panelGroup id="menu_info" layout="block" style="width: 200px">
			<p:messages />
		</h:panelGroup>
	</ui:define>
	<ui:define name="footer">
		<ui:param name="navBean" value="#{viewTreatmentRequestBean}" />
		<ui:param name="navAction" value="goBack" />
		<ui:param name="navTitle" value="Back" />
		<ui:include src="/template/footer_bean_navigation.xhtml" />
	</ui:define>
</ui:composition>
</html>